library(psych)

fa.parallel(
  USJudgeRatings[,-1], fa = 'pc', n.iter = 100,
  show.legend = FALSE,
  main = 'Scree plot with parallel analysis'
)

pc <- principal(USJudgeRatings[, -1], nfactors = 1)
pc

fa.parallel(
  Harman23.cor$cov, n.obs = 302, fa = 'pc', n.iter = 100,
  show.legend = FALSE, main = 'Scree plot with parallel analysis'
)

pc2 <- principal(Harman23.cor$cov, nfactors = 2, rotate = 'none')
pc2

rc <- principal(Harman23.cor$cov, nfactors = 2, rotate = 'varimax')
rc

pc <- principal(USJudgeRatings[, -1], nfactors = 1, scores = TRUE)
head(pc)

cor(USJudgeRatings$CONT, pc$scores)

rc <- principal(Harman23.cor$cov, nfactors = 2, rotate = 'varimax')
round(unclass(rc$weights), 2)

